/*
 *
 *      Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: lengleng (wangiegie@gmail.com)
 *
 */

package com.pig4cloud.pigx.admin.api.entity;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 组织机构
 *
 * @author lfx
 * @since 2018-01-22
 */
@Data
@Schema(description = "组织机构")
@EqualsAndHashCode(callSuper = true)
public class MechanismDept extends Model<MechanismDept> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    @Schema(description = "主键")
    private String id;

    /**
     * 部门名称
     */
    @Schema(description = "部门名称")
    private String deptName;

    /**
     * 部门编码
     */
    @Schema(description = "部门编码")
    private String deptCode;

    /**
     * 父级部门id
     */
    @Schema(description = "父级部门编码")
    private String parentCode;

    /**
     * 描述
     */
    @Schema(description = "描述")
    private String description;

    /**
     * 状态 0停用  1启用
     */
    @Schema(description = "状态")
    private String status;

    /**
     * 排序
     */
    @Schema(description = "排序值")
    private Integer sortOrder;

    /**
     * 是否删除 1：已删除 0：正常
     */
    @TableLogic
    @Schema(description = "删除标记,1:已删除,0:正常")
    @TableField(fill = FieldFill.INSERT)
    private String delFlag;

    private void checkStatus(MechanismDept dept){
        if(ObjectUtil.isEmpty(dept)){
            return;
        }
        if(ObjectUtil.isEmpty(dept.getStatus())){
            dept.setStatus("1");
        }
    }

}
